package com.utils;

import com.alibaba.fastjson.JSON;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;

public class ResponseUtil {
	
	public static void writeJson(HttpServletResponse resp, RestResponse restResponse) throws IOException {
		resp.setContentType("text/json; charset=utf-8");
		resp.setHeader("Access-Control-Allow-Origin", "*");
		resp.setHeader("Access-Control-Allow-Method", "POST,GET");
		resp.setCharacterEncoding("UTF-8");
		PrintWriter writer;
		writer = resp.getWriter();
		writer.write(JSON.toJSONString(restResponse));
		writer.flush();
		writer.close();
	}

}
